<template>
  <div class="rightGoods">
    <!-- 图片 -->
    <div class="banner" v-if="bannerList.length ===1">
      <img class="bannerImg" :src="bannerList[0].picUrl" alt="">
    </div>
    <!--轮播 -->
    <div class="banner" v-else>
      <van-swipe class="my-swipe" ref="swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item v-for="banner in bannerList" :key="banner.id">
          <img :src="banner.picUrl" alt="">
        </van-swipe-item>
      </van-swipe>
    </div>
    <!-- 商品 -->
    <virtual-list class="cateList"
      style="height: 450px; overflow-y: auto;"
      :data-key="'id'"
      :data-sources="categoryGroupList"
      :data-component="itemComponent"
      :keeps="5"
    />
  </div>
</template>

<script>
// import Vue from 'vue'
// import { Swipe, SwipeItem } from 'vant';
// Vue.use(Swipe);
// Vue.use(SwipeItem);

 import Item from './Item'
import VirtualList from 'vue-virtual-scroll-list'

export default {
  name: 'CateList',
  props: ['categoryGroupList', 'bannerList'],

  data () {
    return {
      itemComponent: Item,
    }
  },
  components: { 'virtual-list': VirtualList },

  methods: {
    toSubCateList(category) {
      this.$router.push({
        path: '/subcateList',
        query: {
          categoryId: category.superCategoryId,
          subCategoryId: category.id,
          categoryType: category.categoryType,
        }
      });
    }
  }
}
</script>

<style lang="less">
.rightGoods {
  margin-left: 81px;
}
.cateList {
  // margin-left: 81px;
  width: 264px;
  .title {
    text-align: left;
    overflow: hidden;
    text-align: left;
    font-size: 14px;
    padding-bottom: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid #d9d9d9;
    color: #333;
    font-weight: 700;
    font-family: PingFangSC-Light, helvetica, Heiti SC;
  }
}
.rightGoods {
  padding: 15px 15px 50px;
  height: 100%;
  // overflow: hidden;
  box-sizing: border-box;
  .banner {
    width: 264px;
    height: 96px;
    margin-bottom: 16px;
    .bannerImg {
      width: 264px;
      height: 96px;
    }
    .my-swipe {
      width: 264px;
      height: 100%;
      .van-swipe-item {
        width: 264px;
        height: 100%;
        img {
          width: 264px;
          height: 100%;
        }
      }
      ::v-deep .van-swipe__indicator {
        width: 20px;
        height: 1.5px;
        border-radius: 0;
      }
    }
  }
  .cateList {
    margin-bottom: 6px;
    .list {
      width: 264px;
      .cateItem {
        display: inline-block;
        width: 72px;
        margin-right: 24px;
        &:nth-child(3n) {
          margin-right: 0;
        }
        .itemImg {
          width: 72px;
          height: 72px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .name {
          height: 34px;
          text-align: center;
          line-height: 34px;
          color: #333;
          display: block;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
          text-overflow: ellipsis;
          font-size: 14px;
        }
      }
    }
  }
}
</style>
